//
//  POPView.swift
//  VenusTodo
//
//  Created by 文显庆 on 2021/10/12.
//

//添加任务成功后的弹窗视图

import SwiftUI

struct POPView: View {
    var preView: AddThingView
    @Binding var isPopup: Bool
    var body: some View {
        ZStack {
            Rectangle().fill(Color.init(red: 243/255, green: 243/255, blue: 243/255))
                .edgesIgnoringSafeArea(/*@START_MENU_TOKEN@*/.all/*@END_MENU_TOKEN@*/)
                .brightness(-0.9) //忽略安全区域的限制
                .opacity(isPopup ? 0.6 : 0)  //  设置透明度
            ZStack(alignment: .center) {
                RoundedRectangle(cornerRadius: 30)
                    .fill(Color.white)
                    .frame(height: 500)
                VStack {
                    VStack(alignment: .leading){
                        Spacer()
                        HStack {
                            Spacer()
                            Image(systemName: "multiply")
                                .font(.system(size: 28))
                                .foregroundColor(.gray)
                                .onTapGesture {
                                    self.isPopup.toggle()
                                }
                        }.frame(width: UIScreen.main.bounds.width * 0.7)
                        HStack {
                            Image(systemName: "hand.point.right.fill")
                                .font(.system(size: 48))
                                .foregroundColor(.orange)
                                .padding(.bottom, 30)
                            Text("添加成功！").font(.system(size:  32)).foregroundColor(Color.black)
                        }
                        Button(action: {
                            self.preView.isPressed_Pop.toggle()
                            self.preView.preView.isPressed_addView.toggle()
                            //self.isPopup.toggle()
                        }) {
                            Text("Thank You").bold().frame(width: UIScreen.main.bounds.width * 0.7, height: 60)
                                .background(Color.red)
                                .foregroundColor(.white)
                                .cornerRadius(10)
                                .font(.system(size: 20))
                        }.padding(.top, 60)
                        Spacer()
                            
                    }
                    Spacer()
                }
                .frame(width: UIScreen.main.bounds.width * 0.7)
                
            }
            .offset(x: 0, y: isPopup ? 0 : UIScreen.main.bounds.height)
            .animation(.spring()) //飞入动画
            .padding(.leading, 20)
            .padding(.trailing, 20)
        }
    }
}
/*
#if DEBUG
struct POPView_Previews: PreviewProvider {
    static var previews: some View {
        POPView(is)
    }
}
#endif
 */
